package pl.put.to.classification;

import java.io.IOException;

import pl.put.to.classification.data.DataSet;
import pl.put.to.classification.data.DataSetManager;
import pl.put.to.classification.newton.NewtonRaphsonClassification;
import pl.put.to.classification.verification.error.BooleanErrorVerifcator;
import pl.put.to.classification.verification.error.LogisticErrorVerifcator;

public class NewtonRaphsonEntryPoint {
	public static void main(String[] args) {

		try {
			allDataLogisticError();

			allDataBooleanError();

			halfDataBooleanError();

		} catch (Exception e) {
			e.printStackTrace();
		}

	}

	private static void allDataLogisticError() throws IOException {
		System.out.println("Whole data, logistic error:");
		NewtonRaphsonClassification newtonRaphson = new NewtonRaphsonClassification(new LogisticErrorVerifcator());

		DataSet data = new DataSet("data/spambase.data");

		newtonRaphson.train(data, data);
	}

	private static void allDataBooleanError() throws IOException {
		System.out.println("Whole data, 0/1 error:");
		NewtonRaphsonClassification newtonRaphson = new NewtonRaphsonClassification(new BooleanErrorVerifcator());

		DataSet data = new DataSet("data/spambase.data");

		newtonRaphson.train(data, data);
	}

	private static void halfDataBooleanError() throws IOException {
		System.out.println("Half train and half test data, 0/1 error:");
		NewtonRaphsonClassification newtonRaphson = new NewtonRaphsonClassification(new BooleanErrorVerifcator());

		DataSet data = new DataSet("data/spambase.data");
		DataSetManager dataSetManager = new DataSetManager(data);
		dataSetManager.divideDataSetIntoTrainAndTest(0.5);

		newtonRaphson.train(dataSetManager.getTrainDataSet(), dataSetManager.getTestDataSet());
	}
}
